<?php


namespace RedMVC\Auth\Storage;
use RedMVC;

/**
 * Session class
 *  
 * @category    RedMVC
 * @package     Auth
 * @subpackage  Storage 
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class Session implements IStorage{

    const SESSION_NAME = 'RedMVC_Auth';
    
    protected $_sessionName;

    public function __construct($sessionName = self::SESSION_NAME){
        $this->_sessionName = $sessionName;
    }

    public function hasAuthData(){
        return isset(RedMVC\Session::getInstance()->{$this->_sessionName});
    }

    public function read(){        
        return RedMVC\Session::getInstance()->{$this->_sessionName};
    }
    
    public function write(array $authData){
        RedMVC\Session::getInstance()->{$this->_sessionName} = $authData;
    }
    
    public function clear(){        
        unset(RedMVC\Session::getInstance()->{$this->_sessionName});
    }

}